package com.mlz.mlzmall.ui.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mlz.mlzmall.R;
import com.mlz.mlzmall.ui.activity.act.address.postCodeToPCD;
import com.mlz.mlzmall.ui.activity.act.personal.ReceiveAddress;
import com.mlz.mlzmall.ui.adapter.base.BaseMallAdapter;
import com.mlz.mlzmall.ui.adapter.base.MallHolder;
import com.mlz.mlzmall.ui.adapter.base.ShopMallAdapter;
import com.mlz.mlzmall.ui.model.AddressListBean;
import com.mlz.mlzmall.ui.model.AddressListBean.DataBean.ListBean;
import com.mlz.mlzmall.ui.utils.util.LogUtils;

import java.util.List;

/**
 * Created by yhf on 2016/5/20.
 */
public class AddressAdapter extends ShopMallAdapter<ListBean> {
    public AddressAdapter(Activity activity, List<ListBean> list, int address_item) {
        super(activity, list, address_item);

    }

    @Override
    public void convert(MallHolder holder, ListBean listBean) {
        holder.setText(R.id.tv_name, listBean.getFullname());
        holder.setText(R.id.tv_phone_number, listBean.getShippingTelephone());
        TextView tv = holder.getItemView(R.id.tv_default);
        postCodeToPCD ppp = new postCodeToPCD(activity);//获取省市县
        String code = listBean.getRegionCode() + "";
        String province = ppp.province(code + "");
        String city = ppp.city(code + "");
        String area = ppp.district(code + "");
        LogUtils.d("地址：" + province + city + area + listBean.getAddress());
        holder.setText(R.id.tv_address, province + "\t" + city + "\t" + area + "\t" + listBean.getAddress());
        if (listBean.isDefaultAddress() == true) {
            tv.setVisibility(View.VISIBLE);
        } else {
            tv.setVisibility(View.GONE);
        }
    }

}
